/**
 * WMS CSS重置样式
 * 
 * 提供一致的跨浏览器基础样式
 * 基于现代CSS重置最佳实践
 */

/* ================================
 * 现代CSS重置 - Modern CSS Reset
 * ================================ */

/* 盒模型重置 */
*,
*::before,
*::after {
  box-sizing: border-box;
}

/* 移除默认边距 */
* {
  margin: 0;
  padding: 0;
}

/* 根元素设置 */
html {
  font-size: 14px; /* 基础字体大小 */
  line-height: 1.5; /* 基础行高 */
  -webkit-text-size-adjust: 100%; /* 防止iOS字体放大 */
  -ms-text-size-adjust: 100%; /* 防止Windows Phone字体放大 */
  -webkit-font-smoothing: antialiased; /* 字体平滑 */
  -moz-osx-font-smoothing: grayscale; /* 字体平滑 */
  text-rendering: optimizeLegibility; /* 文本渲染优化 */
}

/* 身体元素设置 */
body {
  font-family: var(--wms-font-family);
  font-size: var(--wms-font-size-sm);
  line-height: var(--wms-line-height-md);
  color: var(--wms-text-color-primary);
  background-color: var(--wms-bg-light);
  overflow-x: hidden; /* 防止水平滚动 */
  min-height: 100vh; /* 最小高度为视窗高度 */
}

/* 标题元素重置 */
h1, h2, h3, h4, h5, h6 {
  font-weight: var(--wms-font-weight-medium);
  line-height: var(--wms-line-height-sm);
  margin: 0;
  color: var(--wms-text-color-primary);
}

h1 { font-size: var(--wms-font-size-xxxl); }
h2 { font-size: var(--wms-font-size-xxl); }
h3 { font-size: var(--wms-font-size-xl); }
h4 { font-size: var(--wms-font-size-lg); }
h5 { font-size: var(--wms-font-size-md); }
h6 { font-size: var(--wms-font-size-sm); }

/* 段落元素 */
p {
  margin: 0;
  line-height: var(--wms-line-height-md);
}

/* 链接元素 */
a {
  color: var(--wms-link-color);
  text-decoration: none;
  transition: var(--wms-transition-base);
  cursor: pointer;
}

a:hover {
  color: var(--wms-link-color-hover);
  text-decoration: underline;
}

a:active {
  color: var(--wms-link-color-active);
}

a:focus {
  outline: 2px solid var(--wms-primary-color);
  outline-offset: 2px;
}

/* 列表元素 */
ul, ol {
  list-style: none;
  margin: 0;
  padding: 0;
}

li {
  margin: 0;
  padding: 0;
}

/* 图片元素 */
img {
  max-width: 100%;
  height: auto;
  border: 0;
  display: block;
}

/* 表格元素 */
table {
  border-collapse: collapse;
  border-spacing: 0;
  width: 100%;
}

th, td {
  text-align: left;
  vertical-align: top;
  padding: 0;
}

/* 表单元素重置 */
button,
input,
optgroup,
select,
textarea {
  font-family: inherit;
  font-size: inherit;
  line-height: inherit;
  margin: 0;
  padding: 0;
  border: none;
  background: none;
  color: inherit;
}

/* 按钮元素 */
button {
  cursor: pointer;
  background: transparent;
  border: none;
  outline: none;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

/* 输入框元素 */
input,
textarea,
select {
  outline: none;
  background-color: transparent;
  border: none;
  resize: none;
}

input::placeholder,
textarea::placeholder {
  color: var(--wms-text-color-placeholder);
  opacity: 1;
}

/* 移除IE10+的清除按钮 */
input::-ms-clear,
input::-ms-reveal {
  display: none;
}

/* 移除Chrome的自动填充背景 */
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus {
  -webkit-box-shadow: 0 0 0 1000px var(--wms-bg-white) inset !important;
  -webkit-text-fill-color: var(--wms-text-color-primary) !important;
}

/* 选择框重置 */
select {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
}

/* 移除数字输入框的步进器 */
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

input[type="number"] {
  -moz-appearance: textfield;
}

/* 复选框和单选框 */
input[type="checkbox"],
input[type="radio"] {
  width: auto;
  height: auto;
}

/* 文件输入框 */
input[type="file"] {
  width: 100%;
}

/* 范围输入框 */
input[type="range"] {
  width: 100%;
}

/* 进度条 */
progress {
  vertical-align: baseline;
}

/* 详情元素 */
details {
  display: block;
}

summary {
  display: list-item;
  cursor: pointer;
}

/* 模板元素 */
template {
  display: none;
}

/* 隐藏元素 */
[hidden] {
  display: none !important;
}

/* ================================
 * 可访问性增强 - Accessibility
 * ================================ */

/* 减少动画偏好 */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* 高对比度模式支持 */
@media (prefers-contrast: high) {
  :root {
    --wms-border-color: #000000;
    --wms-text-color-primary: #000000;
    --wms-bg-white: #ffffff;
  }
}

/* 焦点可见性 */
:focus-visible {
  outline: 2px solid var(--wms-primary-color);
  outline-offset: 2px;
}

/* 屏幕阅读器专用内容 */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.sr-only-focusable:focus {
  position: static;
  width: auto;
  height: auto;
  padding: inherit;
  margin: inherit;
  overflow: visible;
  clip: auto;
  white-space: normal;
}

/* ================================
 * 打印样式重置 - Print Reset
 * ================================ */

@media print {
  *,
  *::before,
  *::after {
    background: transparent !important;
    color: #000 !important;
    box-shadow: none !important;
    text-shadow: none !important;
  }

  a,
  a:visited {
    text-decoration: underline;
  }

  a[href]::after {
    content: " (" attr(href) ")";
  }

  abbr[title]::after {
    content: " (" attr(title) ")";
  }

  a[href^="#"]::after,
  a[href^="javascript:"]::after {
    content: "";
  }

  pre {
    white-space: pre-wrap !important;
  }

  pre,
  blockquote {
    border: 1px solid #999;
    page-break-inside: avoid;
  }

  thead {
    display: table-header-group;
  }

  tr,
  img {
    page-break-inside: avoid;
  }

  p,
  h2,
  h3 {
    orphans: 3;
    widows: 3;
  }

  h2,
  h3 {
    page-break-after: avoid;
  }
}

/* ================================
 * 特殊浏览器适配 - Browser Specific
 * ================================ */

/* Safari特殊处理 */
@supports (-webkit-appearance: none) {
  input[type="search"] {
    -webkit-appearance: none;
  }
  
  input[type="search"]::-webkit-search-decoration,
  input[type="search"]::-webkit-search-cancel-button,
  input[type="search"]::-webkit-search-results-button,
  input[type="search"]::-webkit-search-results-decoration {
    -webkit-appearance: none;
  }
}

/* Firefox特殊处理 */
@-moz-document url-prefix() {
  /* Firefox专用样式 */
  input[type="number"] {
    -moz-appearance: textfield;
  }
}

/* Edge特殊处理 */
@supports (-ms-ime-align: auto) {
  /* Edge专用样式 */
  input::-ms-clear,
  input::-ms-reveal {
    display: none;
  }
}

/* ================================
 * 性能优化 - Performance
 * ================================ */

/* 启用硬件加速 */
.wms-gpu-accelerated {
  transform: translateZ(0);
  -webkit-transform: translateZ(0);
  will-change: transform;
}

/* 优化重排重绘 */
.wms-optimize-repaint {
  will-change: auto;
  contain: layout style paint;
}

/* 滚动优化 */
.wms-smooth-scroll {
  scroll-behavior: smooth;
}

.wms-scroll-container {
  overflow: auto;
  -webkit-overflow-scrolling: touch; /* iOS平滑滚动 */
}

/* ================================
 * 兼容性修复 - Compatibility Fixes
 * ================================ */

/* IE11兼容性修复 */
@media screen and (-ms-high-contrast: active), (-ms-high-contrast: none) {
  /* IE11专用样式 */
  .wms-flex-container {
    display: -ms-flexbox;
    display: flex;
  }
  
  .wms-flex-item {
    -ms-flex: 1;
    flex: 1;
  }
}

/* 移动端适配 */
@media (max-width: 768px) {
  html {
    font-size: 12px; /* 移动端基础字体调整 */
  }
  
  body {
    -webkit-text-size-adjust: none; /* 禁用iOS字体缩放 */
  }
  
  /* 触摸优化 */
  .wms-touchable {
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
    touch-action: manipulation;
  }
}